﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;

namespace Locator.Admin.Views
{
    public class StoreScannerPresenter : Presenter<IStoreScannerView>, IDisposable
    {
        private readonly IAdminController controller;

        public StoreScannerPresenter([CreateNew] IAdminController controller)
        {
            this.controller = controller;
        }

        public override void OnViewLoaded()
        {
        }

        public override void OnViewInitialized()
        {
        }

        public void OnScan()
        {
            string results = this.controller.ScanStores(null);
            this.View.SetResults(results);
        }

        public void Dispose()
        {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (this.controller != null)
                {
                    this.controller.Dispose();
                }
            }
        }

        ~StoreScannerPresenter()
        {
            this.Dispose(false);
        }
    }
}




